import { request } from '@/request/request';
import { Cart } from "@/api/cart/type";
// @ts-ignore


/**
 * 获取购物车数量.
 * @param data
 */
export const getCartsNumber = (data: any): Promise<any> => {
    return request({ url: '/mall/cart/cartsNumber', data, method: 'GET' })
}


/**
 * 加入购物车.
 * @param data
 */
export const storeCart = (data: Cart.storeCartParam): Promise<any> => {
    return request({ url: '/mall/cart/storeCart', data, method: 'POST' })
}

/**
 * 购物车列表.
 * @param data
 */
export const getCartList = (data: any): Promise<any> => {
    return request({ url: '/mall/cart/cartList', data, method: 'GET' })
}

/**
 * 更新购物车商品数量.
 * @param data
 */
export const updateQuantity = (data: Cart.updateQuantityParam): Promise<any> => {
    return request({ url: '/mall/cart/updateQuantity', data, method: 'POST' })
}

/**
 * 删除商品.
 * @param data cart_ids [1,2,3]
 */
export const deleteProduct = (data: any): Promise<any> => {
    return request({ url: '/mall/cart/deleteProduct', data, method: 'POST' })
}

/**
 * 购物车结算数据预览.
 * @param data
 */
export const beforeCheckoutByCart = (data: any): Promise<any> => {
    return request({ url: '/mall/cart/beforeCheckout', data, method: 'POST' })
}

/**
 * 购物车确认结算 生成订单.
 * @param data
 */
export const cartConfirmCheckout = (data: any): Promise<any> => {
    return request({ url: '/mall/cart/confirmCheckout', data, method: 'POST' })
}
